
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>VueCli 3 项目配置 · 《前端学习笔记》</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="XiaoChen">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-pageview-count/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-ancre-navigation/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../Vue3/Vue3探索.html" />
    
    
    <link rel="prev" href="使用 VueCli 3.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">前言</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Android</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../Android/Android 多包名打包应用.html">
            
                <a href="../Android/Android 多包名打包应用.html">
            
                    
                    Android 多包名打包应用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="../Android/Android UI美化之 shape的使用及其属性总结.html">
            
                <a href="../Android/Android UI美化之 shape的使用及其属性总结.html">
            
                    
                    Android UI美化之 shape的使用及其属性总结
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">ReactNative</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../ReactNative/CodePush 热更新配置及使用.html">
            
                <a href="../ReactNative/CodePush 热更新配置及使用.html">
            
                    
                    CodePush 热更新配置及使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../ReactNative/已有Android工程 集成React Native.html">
            
                <a href="../ReactNative/已有Android工程 集成React Native.html">
            
                    
                    已有Android工程 集成React Native
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Egret</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../Egret/Egret 白鹭引擎参考资料.html">
            
                <a href="../Egret/Egret 白鹭引擎参考资料.html">
            
                    
                    Egret 白鹭引擎参考资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../Egret/EGER PRO.html">
            
                <a href="../Egret/EGER PRO.html">
            
                    
                    EGER PRO
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../Egret/Egret 寻路.html">
            
                <a href="../Egret/Egret 寻路.html">
            
                    
                    Egret 寻路
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">工具</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../Tools/homebrew 使用.html">
            
                <a href="../Tools/homebrew 使用.html">
            
                    
                    homebrew 使用
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../Tools/git 使用.html">
            
                <a href="../Tools/git 使用.html">
            
                    
                    git 使用
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">小程序</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../MiniApp/Atom 完美支持 WePY 小程序开发.html">
            
                <a href="../MiniApp/Atom 完美支持 WePY 小程序开发.html">
            
                    
                    Atom 完美支持 WePY 小程序开发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../MiniApp/Atom 插件安装慢解决方案.html">
            
                <a href="../MiniApp/Atom 插件安装慢解决方案.html">
            
                    
                    Atom 插件安装慢解决方案
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="Web 前端环境搭建.html">
            
                <a href="Web 前端环境搭建.html">
            
                    
                    Web 前端环境搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="Vue 项目搭建.html">
            
                <a href="Vue 项目搭建.html">
            
                    
                    Vue 项目搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="初识 VueCli 3.html">
            
                <a href="初识 VueCli 3.html">
            
                    
                    初识 VueCli 3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="使用 VueCli 3.html">
            
                <a href="使用 VueCli 3.html">
            
                    
                    使用 VueCli 3
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="7.5" data-path="VueCli 3 项目配置.html">
            
                <a href="VueCli 3 项目配置.html">
            
                    
                    VueCli 3 项目配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="../Vue3/Vue3探索.html">
            
                <a href="../Vue3/Vue3探索.html">
            
                    
                    初识 Vue3
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">微前端</li>
        
        
    
        <li class="chapter " data-level="8.1" data-path="../MicroApp/qiankun/">
            
                <a href="../MicroApp/qiankun/">
            
                    
                    qiankun
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">团队成长</li>
        
        
    
        <li class="chapter " data-level="9.1" data-path="../Team/Web前端开发规范.html">
            
                <a href="../Team/Web前端开发规范.html">
            
                    
                    开发规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="../Team/Web团队建设--npm私库搭建.html">
            
                <a href="../Team/Web团队建设--npm私库搭建.html">
            
                    
                    私库搭建
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="9.3" data-path="../Team/Web团队建设--自定义脚手架.html">
            
                <a href="../Team/Web团队建设--自定义脚手架.html">
            
                    
                    脚手架搭建
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >VueCli 3 项目配置</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <div id="anchor-navigation-ex-navbar"><i class="fa fa-anchor"></i><ul><li><span class="title-icon "></span><a href="#vue-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x4E09;----vuecli-3-&#x9879;&#x76EE;&#x914D;&#x7F6E;"><b></b>Vue &#x5B66;&#x4E60;&#x7B14;&#x8BB0; (&#x4E09;) -- VueCli 3 &#x9879;&#x76EE;&#x914D;&#x7F6E;</a></li><ul><li><span class="title-icon "></span><a href="#vueconfigjs"><b></b>vue.config.js</a></li></ul></ul></div><a href="#vue-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x4E09;----vuecli-3-&#x9879;&#x76EE;&#x914D;&#x7F6E;" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h1 id="vue-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x4E09;----vuecli-3-&#x9879;&#x76EE;&#x914D;&#x7F6E;"><a name="vue-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x4E09;----vuecli-3-&#x9879;&#x76EE;&#x914D;&#x7F6E;" class="anchor-navigation-ex-anchor" href="#vue-&#x5B66;&#x4E60;&#x7B14;&#x8BB0;-&#x4E09;----vuecli-3-&#x9879;&#x76EE;&#x914D;&#x7F6E;"><i class="fa fa-link" aria-hidden="true"></i></a>Vue &#x5B66;&#x4E60;&#x7B14;&#x8BB0; (&#x4E09;) -- VueCli 3 &#x9879;&#x76EE;&#x914D;&#x7F6E;</h1>
<p>&#x524D;&#x9762;&#x7684;&#x6587;&#x7AE0;&#x5DF2;&#x7ECF;&#x7B80;&#x5355;&#x63D0;&#x5230;&#x8FC7; <code>VueCli 3</code> &#x7684;&#x9879;&#x76EE;&#x914D;&#x7F6E;&#xFF0C;&#x5728; <code>2.0</code> &#x7248;&#x672C;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x8981;&#x4FEE;&#x6539;&#x9879;&#x76EE;&#x914D;&#x7F6E;&#x53EF;&#x4EE5;&#x5728; <code>build</code> &#x548C; <code>config</code> &#x76EE;&#x5F55;&#x4E0B;&#x8FDB;&#x884C;&#x4FEE;&#x6539;&#xFF0C;&#x800C;&#x5728; <code>3.0</code> &#x7248;&#x672C;&#x4E2D;&#x8981;&#x65B0;&#x5EFA; <code>vue.config.js</code> &#x6587;&#x4EF6;&#x7136;&#x540E;&#x5728;&#x91CC;&#x9762;&#x5199;&#x9879;&#x76EE;&#x6240;&#x9700;&#x914D;&#x7F6E;&#x3002;
&#x90A3;&#x4E48;&#x95EE;&#x9898;&#x6765;&#x4E86;&#xFF0C;&#x6211;&#x4EEC;&#x8981;&#x600E;&#x4E48;&#x914D;&#x7F6E;&#x5462;&#xFF1F;&#x522B;&#x6025;&#xFF0C;&#x4E0B;&#x9762;&#x6765;&#x8BB2;&#x3002;</p>
<h2 id="vueconfigjs"><a name="vueconfigjs" class="anchor-navigation-ex-anchor" href="#vueconfigjs"><i class="fa fa-link" aria-hidden="true"></i></a>vue.config.js</h2>
<p><code>vue.config.js</code> &#x662F;&#x4E00;&#x4E2A;&#x53EF;&#x9009;&#x7684;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x5982;&#x679C;&#x9879;&#x76EE;&#x7684; (&#x548C; <code>package.json</code> &#x540C;&#x7EA7;&#x7684;) &#x6839;&#x76EE;&#x5F55;&#x4E2D;&#x5B58;&#x5728;&#x8FD9;&#x4E2A;&#x6587;&#x4EF6;&#xFF0C;&#x90A3;&#x4E48;&#x5B83;&#x4F1A;&#x88AB; <code>@vue/cli-service</code> &#x81EA;&#x52A8;&#x52A0;&#x8F7D;&#x3002;</p>
<p>&#x5148;&#x4E0A;&#x4E00;&#x4EFD;&#x5B8C;&#x6574;&#x914D;&#x7F6E;&#xFF1A;</p>
<pre><code>module.exports = {
    // &#x57FA;&#x672C;&#x8DEF;&#x5F84;
    baseUrl: &apos;/&apos;,
    // &#x8F93;&#x51FA;&#x6587;&#x4EF6;&#x76EE;&#x5F55;
    outputDir: &apos;dist&apos;,
    // eslint-loader &#x662F;&#x5426;&#x5728;&#x4FDD;&#x5B58;&#x7684;&#x65F6;&#x5019;&#x68C0;&#x67E5;
    lintOnSave: true,
    // use the full build with in-browser compiler?
    // https://vuejs.org/v2/guide/installation.html#Runtime-Compiler-vs-Runtime-only
    compiler: false,
    // webpack&#x914D;&#x7F6E;
    // see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
    chainWebpack: () =&gt; {},
    configureWebpack: () =&gt; {},
    // vue-loader &#x914D;&#x7F6E;&#x9879;
    // https://vue-loader.vuejs.org/en/options.html
    vueLoader: {},
    // &#x751F;&#x4EA7;&#x73AF;&#x5883;&#x662F;&#x5426;&#x751F;&#x6210; sourceMap &#x6587;&#x4EF6;
    productionSourceMap: true,
    // css&#x76F8;&#x5173;&#x914D;&#x7F6E;
    css: {
        // &#x662F;&#x5426;&#x4F7F;&#x7528;css&#x5206;&#x79BB;&#x63D2;&#x4EF6; ExtractTextPlugin
        extract: true,
        // &#x5F00;&#x542F; CSS source maps?
        sourceMap: false,
        // css&#x9884;&#x8BBE;&#x5668;&#x914D;&#x7F6E;&#x9879;
        loaderOptions: {},
        // &#x542F;&#x7528; CSS modules for all css / pre-processor files.
        modules: false
    },
    // use thread-loader for babel &amp; TS in production build
    // enabled by default if the machine has more than 1 cores
    parallel: require(&apos;os&apos;).cpus().length &gt; 1,
    // &#x662F;&#x5426;&#x542F;&#x7528;dll
    // See https://github.com/vuejs/vue-cli/blob/dev/docs/cli-service.md#dll-mode
    dll: false,
    // PWA &#x63D2;&#x4EF6;&#x76F8;&#x5173;&#x914D;&#x7F6E;
    // see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
    pwa: {},
    // webpack-dev-server &#x76F8;&#x5173;&#x914D;&#x7F6E;
    devServer: {
        open: process.platform === &apos;darwin&apos;,
        host: &apos;0.0.0.0&apos;,
        port: 8080,
        https: false,
        hotOnly: false,
        proxy: null, // &#x8BBE;&#x7F6E;&#x4EE3;&#x7406;
        before: app =&gt; {}
    },
    // &#x7B2C;&#x4E09;&#x65B9;&#x63D2;&#x4EF6;&#x914D;&#x7F6E;
    pluginOptions: {
        // ...
    }
}
</code></pre><p>&#x50CF;&#x8FD9;&#x6837;&#xFF0C;&#x6211;&#x4EEC;&#x53EA;&#x9700;&#x8981;&#x5728; <code>vue.config.js</code> &#x4E2D;&#x914D;&#x7F6E;&#x597D;&#x9700;&#x8981;&#x7684;&#x914D;&#x7F6E;&#x5C31;&#x53EF;&#x4EE5;&#x4E86;&#xFF0C;&#x5982;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x4E0B;&#x6211;&#x4EEC;&#x8981;&#x4FEE;&#x6539;&#x7AEF;&#x53E3;&#xFF0C;&#x5219;&#x53EA;&#x9700;&#x914D;&#x7F6E; <code>devServer</code> &#x9009;&#x9879;&#x5373;&#x53EF;&#x3002;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>module.exports = {
    devServer: {
        host: &apos;0.0.0.0&apos;,
        port: 8899,
    }
}
</code></pre><p>&#x8FD9;&#x6837;&#x6211;&#x4EEC;&#x7684;&#x7AEF;&#x53E3;&#x53D8;&#x8BBE;&#x7F6E;&#x4E3A; <code>8899</code> &#x4E86;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &amp; copy zengqing.top 2023 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x66F4;&#x65B0;&#x4E8E;&#xFF1A;
2023-03-25 20:28:51
</span></footer>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="使用 VueCli 3.html" class="navigation navigation-prev " aria-label="Previous page: 使用 VueCli 3">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../Vue3/Vue3探索.html" class="navigation navigation-next " aria-label="Next page: 初识 Vue3">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"VueCli 3 项目配置","level":"7.5","depth":1,"next":{"title":"初识 Vue3","level":"7.6","depth":1,"path":"Vue3/Vue3探索.md","ref":"./Vue3/Vue3探索.md","articles":[]},"previous":{"title":"使用 VueCli 3","level":"7.4","depth":1,"path":"Vue2/使用 VueCli 3.md","ref":"./Vue2/使用 VueCli 3.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","code","pageview-count","chapter-fold","expandable-chapters-small","tbfed-pagefooter","hide-element","ancre-navigation"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright & copy zengqing.top 2023","modify_label":"该文件更新于：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"code":{"copyButtons":true},"hide-element":{"elements":[".gitbook-link"]},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"pageview-count":{},"ancre-navigation":{"showLevel":true,"associatedWithSummary":true,"mode":"float","printLog":false,"multipleH1":true,"float":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"expandable-chapters":{}},"theme":"default","author":"XiaoChen","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"《前端学习笔记》","language":"zh-hans","gitbook":"*","description":"个人学习笔记，记录学习过程中的点点滴滴"},"file":{"path":"Vue2/VueCli 3 项目配置.md","mtime":"2023-03-25T12:28:51.391Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2023-03-26T04:06:26.355Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-pageview-count/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-hide-element/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

